class Solution {
public:
    int lengthAfterTransformations(string s, int t) {
        int n = 1e9 + 7;
        vector<int> window(26);
        long long sum = 0;
        for(char c : s){
            window[c - 'a']++;
            sum++;
        }
        while(t--){
            int tmp = window[25];
            for(int i = 25;i > 0;i--){
                window[i] = window[i - 1]; 
            }
            window[0] = tmp % n;
            window[1] = (window[1] + tmp) % n;
            sum += tmp;
            sum %= n;
        }
        return sum;
    }
};